<?php
$baseurl = JURI::base();

$db = JFactory::getDbo();

$query = $db->getQuery(true);
$query->select("name,clickurl,description,params,type,custombannercode");
$query->from("#__banners");
$query->where("state=1 AND catid=63");
$query->order("id");
$db->setQuery($query);
$lsBannerRight = $db->loadObjectList();

//echo count($lsBannerRight);
foreach ($lsBannerRight as &$bnRight){
	$image = $bnRight->params;
	$obj = json_decode($image);
	if ($bnRight->type==0){
	?>
	<div class="adv">
		<a href="<?php echo $bnRight->clickurl;?>" title="<?php echo $bnRight->name;?>" target="_blank">
			<img src="<?php echo $baseurl.$obj->{'imageurl'};?>" width="<?php echo $obj->{'width'}?>" alt="<?php echo $obj->{'alt'};?>" border="0" />
		</a>
	</div>
	<?php
	}else{
	?>
	<object
		classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
		codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
		<?php if (!empty($obj->{'width'})) echo 'width ="'. $obj->{'width'}.'"';?>
		<?php if (!empty($obj->{'height'})) echo 'height ="'. $obj->{'height'}.'"';?>
	>
		<param name="movie" value="<?php echo $imageurl;?>" />
		<embed
			src="<?php echo $imageurl;?>"
			loop="false"
			pluginspage="http://www.macromedia.com/go/get/flashplayer"
			type="application/x-shockwave-flash"
			<?php if (!empty($obj->{'width'})) echo 'width ="'. $obj->{'width'}.'"';?>
			<?php if (!empty($obj->{'height'})) echo 'height ="'. $obj->{'height'}.'"';?>
		/>
	</object>
	<?php	
	}
}
?>
